from flask import Flask, render_template
from cos import angle
app = Flask(__name__)

#1.  类型   剧情 1 古装 2 惊悚 3 动画 4 科幻 5 动作 6
#2.  国家  大陆 1 港台 2 北美 3 欧洲 4 印度 5 日本 6
#3.  语种  普通话 1  粤语 2 英语 3 其他 4
#4.  时长  90-120  1 120-160 2 160-180 3 180 以上 4
#5.  评分  5以下 1   5-7 2   7-9 3     9 4

datas=[
    {
        "name":"沙漏",
        "img":"1.webp",
        "feature":[1,1,1,2,3]
    },
    {
        "name":"我才不要和你做朋友呢",
        "img":"2.webp",
        "feature":[1,3,1,2,2]
    },
    {
        "name":"绝地战警",
        "img":"3.webp",
        "feature":[6,1,1,2,3]
    },
    {
        "name": "海关战线",
        "img": "4.webp",
        "feature": [4, 6, 1, 2, 3]
    },
    {
        "name": "云边有个小卖部",
        "img": "5.webp",
        "feature": [3, 6, 1, 2, 4]
    },
    {
        "name": "朝云暮雨",
        "img": "6.jpg",
        "feature": [2, 4, 1, 2, 3]
    },
    {
        "name": "梦境",
        "img": "7.jpg",
        "feature": [5, 3, 1, 2, 3]
    },
    {
        "name": "玫瑰的故事",
        "img": "8.jpg",
        "feature": [3, 5, 1, 2, 4]
    },
    {
        "name": "窗边的小豆豆",
        "img": "12.jpg",
        "feature": [4, 6, 4, 2, 3]
    },
    {
        "name": "美国内战",
        "img": "13.jpg",
        "feature": [5, 2, 1, 2, 3]
    },
]

@app.route('/')
def index():
    return render_template('demo.html', datas=datas)
@app.route('/tuijian/<int:id>')
def tuijian(id):
    current=datas[id]["feature"]
    arr=[]
    for i in range(len(datas)):
        if(i!=id):
            obj={}
            a=angle(current, datas[i]["feature"])
            obj["angle"]=a
            obj["id"]=i
            arr.append(a)
    def k(v):
        return v["angle"]
    arr.sort(key=k)
    return render_template("tuijian.html",datas=datas,arr=arr[:5])

if __name__ == '__main__':
    app.run(debug=True)
